<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\widgets\Pjax;

$this->title = "护照审核";
?>

<?PHP Pjax::begin(['id'=>'passport', 'timeout'=>3000, 'linkSelector'=>'#passport a[data-sort], #cruise a[data-page]']);?>
<?=  yii\web\View::registerCssFile("/js/viewer.min.css",['depends' => 'app\assets\AppAsset']) ?>
<?=  yii\web\View::registerJsFile("/js/viewer.min.js",['depends' => 'app\assets\AppAsset']) ?>

<div class="order-customer-passport-check">

    <h2 class="page-header"><small>护照审核</small></h2>

    <?php $form = ActiveForm::begin([
        'action' => ['passport-check'],
        'method' => 'get',
        'options' => ['data-pjax'=>true],
    ]); ?>

    <div class="row">
    	<div class="form-group col-md-3">
			<input type="text" name="OrderCustomer[passport]" id="customer-passport" class="form-control" placeholder="护照号"  value="<?= isset($params['OrderCustomer']['passport']) ? $params['OrderCustomer']['passport'] : '' ?>">
    	</div>

    	<div class="form-group col-md-2">
    	    <?= Html::submitButton(Yii::t('app.order', '查询'), ['class' => 'btn btn-primary']) ?>
    	</div>
    </div>
    <?php ActiveForm::end(); ?>

	<hr>
	<div class="">
		<ul class="list-group" id="galley">
		<?php if($data){	
				foreach($data as $customer){ ?>	
					
			<li class="list-group-item col-md-12">
				<p class='col-md-2'>
					<?= $customer->first_name?> <?=$customer->last_name ?> <br>
					<?= $customer->phone ?>	
				</p>
				<p class='col-md-2'><font><?= $customer->passport ?></font></p>
				<p class='col-md-2'>
					<img src="/<?= $customer->passport_img ?>" data-original="/<?= $customer->passport_img ?>" id="" class="img-responsive img-thumbnail artZoom " >
				</p>
				<p class='col-md-4'>
					<?= $customer->order['product']['name'] ?> <br>
					船&nbsp;&nbsp;&nbsp;期: <?= $customer->order->product->go_time ?><br>
					订单号: <b><?= $customer->order['code'] ?></b>
				</p>
				<p class='col-md-1'>
					<?php if($customer->passport_check == 1){ ?>
						<button class="btn btn-sm btn-info check" data-value="2" data-id="<?= $customer->id ?>" >审核通过</button>
			<!-- button class="btn btn-sm btn-danger check" data-value="3" data-id="</?= $customer->id ?>" >审核失败</button -->
					<?php }elseif($customer->passport_check == 2) { ?>
						<span class="label label-primary">已审核通过</span>		
					<?php }elseif($customer->passport_check == 3) { ?>
						<span class="label label-danger">审核失败</span>		
					<?php } ?>
				</p>
			</li>	
		<?php   } } ?>
		</ul>
	</div>
</div>


	<?php app\components\JsBlock::begin() ?>
	<script type="text/javascript">
	$(".check").click(function() {
		var value = $(this).data("value");
		var id    = $(this).data("id");
	
		$.get("/order/customer/check-save", { passport_check: value, id: id },
			function(data){
			console.log(data);
			if(data){
				window.location.reload();	
			}
		});
	});
	

	var galley =  document.getElementById('galley');

	var viewer;

	viewer = new Viewer(galley, {
		url: 'data-original',
	});

	</script>
	<?php app\components\JsBlock::end() ?> 
<?php Pjax::end(); ?></div>
